package com.liyunc.demo.bundle.user.org.web.resources;

import com.liyunc.demo.bundle.user.org.model.dto.input.OrganizationEnterRequestDto;
import com.liyunc.demo.bundle.user.org.model.dto.output.OrganizationEnterResponseDto;
import com.liyunc.demo.bundle.user.org.model.dto.output.UserOrganizationalAccountDto;
import com.liyunc.demo.bundle.user.org.service.UserOrganizationalAccountService;
import com.liyunc.demo.comp.common.rest.request.PageRequest;
import com.liyunc.demo.comp.common.rest.response.GeneralResponse;
import com.sun.istack.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liyuncong
 * @version 1.0
 * @file UserOrganizationResource
 * @brief UserOrganizationResource
 * @details UserOrganizationResource
 * @date 2022/4/27
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2022/4/27                     liyuncong          Created
 */
@RestController
@RequestMapping(
    value = "/api/v1/organizations",
    produces = MediaType.APPLICATION_JSON_VALUE
)
@RequiredArgsConstructor
public class OrganizationResource {

    @Autowired
    private UserOrganizationalAccountService accountService;

    @RequestMapping(
        method = RequestMethod.POST,
        path = ""
    )
    public GeneralResponse<OrganizationEnterResponseDto> enter(
        @RequestBody OrganizationEnterRequestDto requestDto
    ) {
        return GeneralResponse.of(
            accountService.enter(requestDto).orElse(null)
        );
    }

    public GeneralResponse<UserOrganizationalAccountDto> searchOrganizationalAccounts(
        @RequestParam(name = "keyword", required = false) String keyword,
        @NotNull PageRequest pageRequest
    ) {
        return null;
    }
}
